﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Helpers;
using Newtonsoft.Json;

namespace swagger2apidocv1
{
    class Program
    {
        static async Task Main(string[] args)
        {
            try
            {
                using (var http = new HttpClient())
                {
                    var rsp = await http.GetAsync(@"http://192.168.0.103:9002/api/docs/UiWeb");
                    dynamic api = ObjectEx.JsonTo<dynamic>(await rsp.Content.ReadAsStringAsync());
                    var apidoc = new ApiDoc("apidoc", "apioutput");
                    apidoc.opts.apidoc = true;
                    //var apiInfo = api.info as SwaggerInfo;
                    var apiInfo = ObjectEx.CastAnyTo<SwaggerInfo>(api);
                    apidoc.AddDocInfo(apiInfo);
                    apidoc.Run();
                    Console.WriteLine("Hello World!");
                }
            }
            catch (Exception ex)
            {

            }
        }
    }
}
